package com.tianjipms.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.tianjipms.dao.OpinionMapper;
import com.tianjipms.entity.Opinion;
import com.tianjipms.entity.Vehicle;
import com.tianjipms.service.OpinionService;
import com.tianjipms.utils.Result;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

@Service
@Transactional
public class OpinionServiceImpl extends ServiceImpl<OpinionMapper, Opinion> implements OpinionService {
    @Resource
    private OpinionMapper opinionMapper;
    @Override
    public IPage<Opinion> findOpinionListByPage(IPage<Opinion> page, Long userId) {
        QueryWrapper<Opinion> queryWrapper = new QueryWrapper<Opinion>();
        queryWrapper.like(!ObjectUtils.isEmpty(userId),"user_id", userId);
        return opinionMapper.selectPage(page, queryWrapper);
    }

    @Override
    public Result updateStatusById(Opinion opinion) {
        opinion.setStatus(1);
        opinionMapper.updateById(opinion);
        return Result.ok();
    }
}
